package com.hkx.smipleemps.common.utils;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;
//不能 /*
@WebFilter("*.do")
public class HibernateTransactionFilter  implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//        System.out.println("前处理: 留下买路钱！！！！");

        HibernateUtils.beginSessionTransaction();
        filterChain.doFilter(servletRequest,servletResponse);
        HibernateUtils.commitAndCloseSession();
        //        System.out.println("后处理: 处理后事！！");
    }

    @Override
    public void destroy() {

    }
}
